//
//  JSTFileCache.m
//  JSTMobClick
//
//  Created by 01 on 16/9/22.
//  Copyright © 2016年 Czj. All rights reserved.
//

#import "JSTFileCache.h"
#import "SDWebImageManager.h"
#import "JSTFMDBManager.h"

@interface JSTFileCache ()
{
    CFAbsoluteTime resignTime;  //记录进入后台的时间
}
@end

@implementation JSTFileCache

+ (JSTFileCache *)defaultCache
{
    static JSTFileCache *fileCache;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        fileCache = [[JSTFileCache alloc] init];
    });
    return fileCache;
}

- (id) init
{
    if (self = [super init]) {
        
    }
    return self;
}

- (void)cleanDisk
{
    NSFileManager * fileManager = [[NSFileManager alloc]init];
    
    [fileManager removeItemAtPath:[JSTFMDBManager databaseFilePath] error:nil];
    
    [[SDImageCache sharedImageCache] clearDisk];
    [[SDImageCache sharedImageCache] clearMemory];
}

- (void)clearDisk
{
    
}

- (NSString *)cachePathForKey:(NSString *)key
{
    NSString * pathName = self.cachePath;
    
    if ( NO == [[NSFileManager defaultManager] fileExistsAtPath:pathName])
    {
        [[NSFileManager defaultManager] createDirectoryAtPath:pathName
                                  withIntermediateDirectories:YES
                                                   attributes:nil
                                                        error:NULL];
    }
    
    return [pathName stringByAppendingString:key];
}

@end
